<template>
  <div id="app">
    <router-view v-if="isRouterAlive"></router-view>
  </div>
</template>

<script>
export default  {
  name:  'App',
  provide() {
    return {
      reload: this.reload
    }
  },
  metaInfo() {
        return {
            title: this.$store.state.settings.dynamicTitle && this.$store.state.settings.title,
            titleTemplate: title => {
                return title ? `${title} - ${process.env.VUE_APP_TITLE}` : process.env.VUE_APP_TITLE
            }
        }
    },
  data() {
    return {
      //isRouterAlive控制router-view的显示或隐藏，从而控制页面的再次加载。
      isRouterAlive: true
    }
  },
  methods: {
    //刷新方法
    reload(){
      this.isRouterAlive = false;
      //该方法会在dom更新后执行
      this.$nextTick(function(){
        this.isRouterAlive = true;
      });
    }
  }
}
</script>
